﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyMusicPlay._4._0
{
    public class Music
    {
        public string Id { get; init; }

        public string Name { get; private set; }

        public string Path { get; private set; }

        public string Singer { get; private set; }

        public string MusicListName { get; private set; }

        public int Key { get; private set; }


        private Music() { }
        public Music(string name, string path, string singer, string musicListName, int key)
        {
            Id = Music.GenerateStringID();
            Name = name;
            Path = path;
            Singer = singer;
            MusicListName = musicListName;
            Key = key;
        }

        public void SetName(string name)
        {
            if (string.IsNullOrEmpty(name))
                return;
            this.Name = name;
        }

        public void SetSinger(string singer)
        {
            if (string.IsNullOrEmpty(singer))
                return;
            this.Singer = singer;
        }

        public void SetPath(string path)
        {
            if (string.IsNullOrEmpty(path))
                return;
            this.Path = path;
        }

        public static string GenerateStringID()
        {
            long i = 1;
            foreach (byte b in Guid.NewGuid().ToByteArray())
            {
                i *= ((int)b + 1);
            }
            return string.Format("{0:x}", i - DateTime.Now.Ticks);
        }
    }
}
